/**
 * API接口统一管理
 * 基于JeecgBoot框架的API封装
 */
import HttpUtil from '../utils/http.js';

// 用户认证相关API
export const authApi = {
  // 用户登录
  login: (data) => HttpUtil.post('/sys/user/login', data),
  
  // 获取用户信息
  getUserInfo: () => HttpUtil.get('/sys/user/getUserInfo'),
  
  // 用户登出
  logout: () => HttpUtil.post('/sys/user/logout'),
  
  // 刷新token
  refreshToken: () => HttpUtil.post('/sys/user/refreshToken')
};

// 员工管理相关API
export const employeeApi = {
  // 员工登录
  login: (data) => HttpUtil.post('/sys/employee/login', data),
  
  // 获取员工信息
  getInfo: () => HttpUtil.get('/sys/employee/info'),
  
  // 获取员工列表
  getList: (params) => HttpUtil.get('/sys/employee/list', params),
  
  // 添加员工
  add: (data) => HttpUtil.post('/sys/employee/add', data),
  
  // 更新员工
  update: (data) => HttpUtil.put('/sys/employee/edit', data),
  
  // 删除员工
  delete: (id) => HttpUtil.delete(`/sys/employee/delete/${id}`)
};

// 生产管理相关API
export const productionApi = {
  // 获取生产任务列表
  getTaskList: (params) => HttpUtil.get('/production/task/list', params),
  
  // 获取生产任务详情
  getTaskDetail: (id) => HttpUtil.get(`/production/task/detail/${id}`),
  
  // 创建生产任务
  createTask: (data) => HttpUtil.post('/production/task/create', data),
  
  // 更新生产任务
  updateTask: (data) => HttpUtil.put('/production/task/update', data),
  
  // 删除生产任务
  deleteTask: (id) => HttpUtil.delete(`/production/task/delete/${id}`),
  
  // 获取工艺路线列表
  getProcessRoutes: (params) => HttpUtil.get('/production/process/routes', params),
  
  // 获取生产统计
  getStatistics: (params) => HttpUtil.get('/production/statistics', params)
};

// 库存管理相关API
export const inventoryApi = {
  // 获取库存列表
  getList: (params) => HttpUtil.get('/wms/inventory/list', params),
  
  // 获取库存详情
  getDetail: (id) => HttpUtil.get(`/wms/inventory/detail/${id}`),
  
  // 库存调整
  adjust: (data) => HttpUtil.post('/wms/inventory/adjust', data),
  
  // 库存转移
  transfer: (data) => HttpUtil.post('/wms/inventory/transfer', data),
  
  // 获取库存统计
  getStatistics: () => HttpUtil.get('/wms/inventory/statistics'),
  
  // 盘点相关
  stocktaking: {
    // 创建盘点任务
    create: (data) => HttpUtil.post('/wms/stocktaking/create', data),
    
    // 获取盘点列表
    getList: (params) => HttpUtil.get('/wms/stocktaking/list', params),
    
    // 提交盘点结果
    submit: (data) => HttpUtil.post('/wms/stocktaking/submit', data)
  }
};

// 订单管理相关API
export const orderApi = {
  // 获取订单列表
  getList: (params) => HttpUtil.get('/order/list', params),
  
  // 获取订单详情
  getDetail: (id) => HttpUtil.get(`/order/detail/${id}`),
  
  // 创建订单
  create: (data) => HttpUtil.post('/order/create', data),
  
  // 更新订单
  update: (data) => HttpUtil.put('/order/update', data),
  
  // 删除订单
  delete: (id) => HttpUtil.delete(`/order/delete/${id}`),
  
  // 订单状态变更
  updateStatus: (data) => HttpUtil.post('/order/updateStatus', data)
};

// 客户管理相关API
export const customerApi = {
  // 获取客户列表
  getList: (params) => HttpUtil.get('/customer/list', params),
  
  // 获取客户详情
  getDetail: (id) => HttpUtil.get(`/customer/detail/${id}`),
  
  // 添加客户
  add: (data) => HttpUtil.post('/customer/add', data),
  
  // 更新客户
  update: (data) => HttpUtil.put('/customer/update', data),
  
  // 删除客户
  delete: (id) => HttpUtil.delete(`/customer/delete/${id}`)
};

// 供应商管理相关API
export const supplierApi = {
  // 获取供应商列表
  getList: (params) => HttpUtil.get('/supplier/list', params),
  
  // 获取供应商详情
  getDetail: (id) => HttpUtil.get(`/supplier/detail/${id}`),
  
  // 添加供应商
  add: (data) => HttpUtil.post('/supplier/add', data),
  
  // 更新供应商
  update: (data) => HttpUtil.put('/supplier/update', data),
  
  // 删除供应商
  delete: (id) => HttpUtil.delete(`/supplier/delete/${id}`)
};

// 系统管理相关API
export const systemApi = {
  // 获取字典数据
  getDictItems: (dictCode) => HttpUtil.get(`/sys/dict/getDictItems/${dictCode}`),
  
  // 文件上传
  upload: (filePath, formData) => HttpUtil.upload('/sys/common/upload', filePath, formData),
  
  // 获取系统配置
  getConfig: () => HttpUtil.get('/sys/config/getConfig'),
  
  // 获取菜单权限
  getPermissions: () => HttpUtil.get('/sys/permission/getUserPermissions')
};

// 统计报表相关API
export const reportApi = {
  // 获取生产统计报表
  getProductionReport: (params) => HttpUtil.get('/report/production', params),
  
  // 获取库存统计报表
  getInventoryReport: (params) => HttpUtil.get('/report/inventory', params),
  
  // 获取销售统计报表
  getSalesReport: (params) => HttpUtil.get('/report/sales', params),
  
  // 获取财务统计报表
  getFinanceReport: (params) => HttpUtil.get('/report/finance', params)
};

// 导出所有API
export default {
  auth: authApi,
  employee: employeeApi,
  production: productionApi,
  inventory: inventoryApi,
  order: orderApi,
  customer: customerApi,
  supplier: supplierApi,
  system: systemApi,
  report: reportApi
};
